#!/usr/bin/env bash


help(){
    cat<<__EOF__
Usage: m restart [--force | --help]

Description: Restart the computer.

Options:
  --help    Show this help message
  --force   Force restart without confirmation

Examples:
  m restart          # Restart computer (needs confirmation)
  m restart --force  # Restart computer (without confirmation)
__EOF__
}

restart(){
    osascript -e 'tell app "loginwindow" to «event aevtrrst»'
}

force_restart(){
   osascript -e 'tell app "System Events" to restart'
}


case $1 in
    --help)
        help
        ;;
    -f|--force)
        force_restart
        ;;
    *)
        restart
        ;;
esac
